package com.example.onlineeducation.mapper

import com.example.onlineeducation.data.constant.ProblemType
import com.example.onlineeducation.data.entity.OptionEntity
import com.example.onlineeducation.data.entity.ProblemEntity
import com.example.onlineeducation.data.json.OnlineExaminationQuestionsJson
import com.yc.jetpacklib.extension.ycToNoEmpty

import com.yc.jetpacklib.mapper.IMapper

class OnlineExaminationQuestionsMapper : IMapper<List<OnlineExaminationQuestionsJson>?, List<ProblemEntity>?> {
    override fun map(input: List<OnlineExaminationQuestionsJson>?): List<ProblemEntity>? {
        return input?.map {
            ProblemEntity(
                it.questionId,
                it.content.ycToNoEmpty(),
                ProblemType.toType(it.type),
                it.options?.map {
                    OptionEntity(
                        it.id.ycToNoEmpty(""),
                        it.content.ycToNoEmpty()
                    )
                }
            )
        }
    }
}

